package com.fzy.silntgym.weight.MSfab.models;

import android.content.Context;
import android.support.annotation.DrawableRes;
import android.text.TextUtils;
import android.text.format.DateFormat;

import com.fzy.silntgym.R;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;

/**
 * Created by 77dfeba on 2016/9/10.
 */

public class ShareNote {
    public static final String NOTICE1 = "欢迎观看教学视频";
    public static final String WORD1 = "点击在线观看即可观看";




    private static final int NUM_WORDS = 4;
    private static final int DATE_RANGE = -10;

    private String title;
    private String note;
    private String info;
    @DrawableRes
    private int infoImage;
    private int color;
    private static int isnotice = 0;

    private ShareNote(String title, String note, String info, int infoImage, int color) {
        this.title = title;
        this.note = note;
        this.info = info;
        this.infoImage = infoImage;
        this.color = color;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public int getInfoImage() {
        return infoImage;
    }

    public void setInfoImage(int infoImage) {
        this.infoImage = infoImage;
    }

    public int getColor() {
        return color;
    }

    public void setColor(int color) {
        this.color = color;
    }

    public static ShareNote randomNote(Context context) {
        String title = "";
        String note = "";
        NoteInfo info = new NoteInfo("", 0);
        int color = getRandomColor(context);
        title = getRandomActivity();
        note = getRandomWords();
        info = getRandomInfo(context);

        return new ShareNote(capitalize(title), note, info.info, info.infoImage, color);
    }

    private static String getRandomActivity() {

        return NOTICE1;
    }

    private static String getRandomWords() {

        return WORD1;
    }





    private static ShareNote.NoteInfo getRandomInfo(Context context) {
        ShareNote.NoteInfo[] infos = new ShareNote.NoteInfo[] { getRandomDate(context) };
        return (ShareNote.NoteInfo) getRandomItem(infos);
    }

    private static ShareNote.NoteInfo getRandomDate(Context context) {
        Calendar cal = Calendar.getInstance();
            cal.add(Calendar.DATE, (int) (Math.random() * 0));
        String date = DateFormat.getMediumDateFormat(context).format(cal.getTime());
        return new ShareNote.NoteInfo(date, R.drawable.ic_event_white_24dp);
    }


    private static int getRandomColor(Context context) {
        int[] colors;
        if (Math.random() >= 0.6) {
            colors = context.getResources().getIntArray(R.array.note_accent_colors);
        } else {
            colors = context.getResources().getIntArray(R.array.note_neutral_colors);
        }
        return colors[((int) (Math.random() * colors.length))];
    }

    private static String capitalize(String str) {
        if (TextUtils.isEmpty(str)) {
            return str;
        }
        return Character.toUpperCase(str.charAt(0)) + str.substring(1);
    }



    private static Object getRandomItem(Object[] objs) {
        return objs[((int) (Math.random() * objs.length))];
    }

    private static class NoteInfo {

        private String info;
        private int infoImage;

        private NoteInfo(String info, int infoImage) {
            this.info = info;
            this.infoImage = infoImage;
        }

    }
}
